/*
 * jQuery Reveal Plugin 1.0
 * www.ZURB.com
 * Copyright 2010, ZURB
 * Free to use under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
*/


(function($) {

/*---------------------------
 Defaults for Reveal
----------------------------*/
	 
/*---------------------------
 Listener for data-reveal-id attributes
----------------------------*/

	$('a[data-reveal-id="myModal"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosSociete").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="myModa2"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosRecrutement").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="myModa3"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosEngagementLivraison").parent().reveal($(this).data());
		
		
	});

	$('a[data-reveal-id="myModa4"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosEngagementPaiement").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="myModa5"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosSEngagementSatisfait").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="myModa6"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosEngagementAssistance").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="myModa7"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosInfosLegales").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="inf200"]').live('click', function(e) {
		e.preventDefault();
		
	$("#myModal>div").load("/infos.html #inf200").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="sup200"]').live('click', function(e) {
		e.preventDefault();
		
	$("#myModal>div").load("/infos.html #sup200").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="myModa10"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #comptant").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="rio"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #rio").parent().reveal($(this).data());
		
		
	});
	
	
	$('a[data-reveal-id="infosBoutique"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosBoutique").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="infosEtapes"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #infosEtapes").parent().reveal($(this).data());
		
		
	});

	
	$('a[data-reveal-id="popChoixMobile"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/popMobile.html #choixMobile1").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popChoixAssurance1"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/popAssurance.html #choixAssurance1").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popChoixAssurance2"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/popAssurance.html #choixAssurance2").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popChoixAssurance3"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/popAssurance.html #choixAssurance3").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popChoixAssurance4"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/popAssurance.html #choixAssurance4").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheZTEF160"]').live('click', function(e) {
		e.preventDefault();

		$("#myModalFiche>div").load("/ficheZTE160.html #ficheProduit").parent().reveal($(this).data());

		
	});
	
	$('a[data-reveal-id="popFicheHuaweiU8350"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheHuaweiU8350.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheZTEBladeS"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheZTEBlade.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheSamsungGalaxyY"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheSamsungGalaxyY.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheBlackberryCurve3G"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheBB9300.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheSamsungGalaxyAce"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheSamsungGalaxyAce.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheSamsungGalaxySII"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheSamsungGalaxyS2.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheIphone4_8goNoir"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheIphone4_8go.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheIphone4s_16goBlanc"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheIphone4s_16goBlanc.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheIphone4s_16goNoir"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheIphone4s_16goNoir.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheIphone4s_32goNoir"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheIphone4s_32goNoir.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="popFicheIphone4s_64goNoir"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalFiche>div").load("/ficheIphone4s_64goNoir.html #ficheProduit").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="autresInformationsLegales"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #autresInformationsLegales").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="mentionsOffres"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModal>div").load("/infos.html #mentionsOffres").parent().reveal($(this).data());
		
		
	});
	
	$('a[data-reveal-id="iphoneApple"]').live('click', function(e) {
		e.preventDefault();
		
		$("#myModalApple>div").load("/apple.html").parent().reveal($(this).data());
		
		
	});
	
	
/*---------------------------
 Extend and Execute
----------------------------*/

    $.fn.reveal = function(options) {
        
        
        var defaults = {  
	    	animation: 'fadeAndPop', //fade, fadeAndPop, none
		    animationspeed: 300, //how fast animtions are
		    closeonbackgroundclick: true, //if you click background will modal close?
		    dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal
    	}; 
    	
        //Extend dem' options
        var options = $.extend({}, defaults, options); 
	
        return this.each(function() {
        
/*---------------------------
 Global Variables
----------------------------*/
        	var modal = $(this),
        		topMeasure  = parseInt(modal.css('top')),
				topOffset = modal.height() + topMeasure,
          		locked = false,
				modalBG = $('.reveal-modal-bg');

/*---------------------------
 Create Modal BG
----------------------------*/
			if(modalBG.length == 0) {
				modalBG = $('<div class="reveal-modal-bg" />').insertAfter(modal);
			}		    
     
/*---------------------------
 Open & Close Animations
----------------------------*/
			//Entrance Animations
			modal.bind('reveal:open', function () {
			  modalBG.unbind('click.modalEvent');
				$('.' + options.dismissmodalclass).unbind('click.modalEvent');
				if(!locked) {
					lockModal();
					if(options.animation == "fadeAndPop") {
						modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'});
						modalBG.fadeIn(options.animationspeed/2);
						modal.delay(options.animationspeed/2).animate({
							"top": $(document).scrollTop()+topMeasure + 'px',
							"opacity" : 1
						}, options.animationspeed,unlockModal());					
					}
					if(options.animation == "fade") {
						modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure});
						modalBG.fadeIn(options.animationspeed/2);
						modal.delay(options.animationspeed/2).animate({
							"opacity" : 1
						}, options.animationspeed,unlockModal());					
					} 
					if(options.animation == "none") {
						modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure});
						modalBG.css({"display":"block"});	
						unlockModal()				
					}
				}
				modal.unbind('reveal:open');
			}); 	

			//Closing Animation
			modal.bind('reveal:close', function () {
			  if(!locked) {
					lockModal();
					if(options.animation == "fadeAndPop") {
						modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
						modal.animate({
							"top":  $(document).scrollTop()-topOffset + 'px',
							"opacity" : 0
						}, options.animationspeed/2, function() {
							modal.css({'top':topMeasure, 'opacity' : 1, 'visibility' : 'hidden'});
							unlockModal();
						});					
					}  	
					if(options.animation == "fade") {
						modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
						modal.animate({
							"opacity" : 0
						}, options.animationspeed, function() {
							modal.css({'opacity' : 1, 'visibility' : 'hidden', 'top' : topMeasure});
							unlockModal();
						});					
					}  	
					if(options.animation == "none") {
						modal.css({'visibility' : 'hidden', 'top' : topMeasure});
						modalBG.css({'display' : 'none'});	
					}		
				}
				modal.unbind('reveal:close');
			});     
   	
/*---------------------------
 Open and add Closing Listeners
----------------------------*/
        	//Open Modal Immediately
    	modal.trigger('reveal:open')
			
			//Close Modal Listeners
			var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent', function () {
			  modal.trigger('reveal:close')
			});
			
			if(options.closeonbackgroundclick) {
				modalBG.css({"cursor":"pointer"})
				modalBG.bind('click.modalEvent', function () {
				  modal.trigger('reveal:close')
				});
			}
			$('body').keyup(function(e) {
        		if(e.which===27){ modal.trigger('reveal:close'); } // 27 is the keycode for the Escape key
			});
			
			
/*---------------------------
 Animations Locks
----------------------------*/
			function unlockModal() { 
				locked = false;
			}
			function lockModal() {
				locked = true;
			}	
			
        });//each call
    }//orbit plugin call
})(jQuery);
        
